package other;

import String.StringUtils;

/**
 * 
 * 断言语句
 *
 */
public class Assert {

	public static void assertEquals(Object o1, Object o2, String errorMessage){
		if (o1 != null && o2 != null){
			if (o1.equals(o2)){
				throw new RuntimeException(errorMessage);
			}
		}else if (o1 == null && o2 == null){
			
		}else{
			throw new RuntimeException(errorMessage);
		}
	}
	
	public static void assertEquals(long l1, long l2, String errorMessage){
		if (l1 != l2){
			throw new RuntimeException(errorMessage);
		}
	}
	
	public static void assertNotNull(Object o, String errorMessage){
		if (o == null){
			throw new RuntimeException(errorMessage);
		}
	}

	public static void assertNotEmpty(String o, String errorMessage){
		if (StringUtils.isEmpty(o)){
			throw new RuntimeException(errorMessage);
		}
	}
	
	/**
	 * Assert that an object is not {@code null} .
	 * <pre class="code">Assert.notNull(clazz, "The class must not be null");</pre>
	 * @param object the object to check
	 * @param message the exception message to use if the assertion fails
	 * @throws IllegalArgumentException if the object is {@code null}
	 */
	public static void notNull(Object object, String message) {
		if (object == null) {
			throw new IllegalArgumentException(message);
		}
	}

	/**
	 * Assert that an object is not {@code null} .
	 * <pre class="code">Assert.notNull(clazz);</pre>
	 * @param object the object to check
	 * @throws IllegalArgumentException if the object is {@code null}
	 */
	public static void notNull(Object object) {
		notNull(object, "[断言失败] - 此参数不可为空");
	}
	
}
